package ipad.asia.service.product;

import ipad.asia.entity.Product;
import ipad.asia.service.product.fallback.ProductFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.List;

@Component
@FeignClient(value ="PROVIDER-PRODUCT")
public interface ProductFeign {
    /**post方式传递Object json
     * 上架商品
     * @param product
     */
    @RequestMapping(value = "/product/saveObj",method = RequestMethod.POST,consumes = "application/json")
     void addObj( Product product);

    @RequestMapping("/product/saveSecKill")
    void addSecKill( @RequestParam(value = "name",required = false) String name,
             @RequestParam(value = "price",required = false) String price,
             @RequestParam(value = "describe",required = false) String describe,
             @RequestParam(value = "photo",required = false) String photo,
             @RequestParam(value = "shopId",required = false) String shopId,
             @RequestParam(value = "kind",required = false) String kind,
             @RequestParam(value = "under",required = false) String under,
             @RequestParam(value = "number",required = false) String number,
             @RequestParam(value = "haveDiscount",required = false) String haveDiscount,
             @RequestParam(value = "haveSell",required = false) String haveSell) ;

    /**
     * 查找商品
     * @param id
     * @return
     */
    @RequestMapping("/product/get/id")
     Product getById(@RequestParam("id") int id) ;
    @RequestMapping("/product/get/name")
     List<Product> findByName(@RequestParam(value = "name",required = false)String name);
    @RequestMapping("/product/get/all")
     List<Product> all();

    /**
     * 根据价格区间查找商品
     * @param down
     * @param up
     * @return
     */
    @RequestMapping("/product/get")
     List<Product> findByPrice(@RequestParam(value = "down",required = false)int down,
                                     @RequestParam(value = "up",required = false)int up);
    @RequestMapping("/product/get/kind")
     List<Product> findByKind(@RequestParam(value = "kind",required = false)String kind);

//    /**
//     * 查询折扣
//     * @param flag
//     * @return
//     */
    @RequestMapping("/product/get/haveDiscount")
     List<Product> findByIsDiscount(@RequestParam(value = "flag",required = false)int flag);
//    //是否下架
//    @RequestMapping("/product/get/under/{flag}")
//     List<Product> findByUndercarriage(@PathVariable(value = "flag",required = false)int flag);
//    //是否卖出
//    @RequestMapping("/product/get/haveSell/{flag}")
//     List<Product> findByHaveSell(@PathVariable(value = "flag",required = false)int flag);
    //删除



    @RequestMapping("/product/delete")
     void DeleteById(@RequestParam(value = "id",required = false)int id);

    @RequestMapping("/product/get/ShopId")
     List<Product> getShopId(@RequestParam(value = "ShopId",required = false)int shopId) throws Exception;



    @RequestMapping("/product/updateNumber")
     void updateNumber(@RequestParam(value = "number",required = false) int number,
                       @RequestParam(value = "id",required = false) int id);


    @RequestMapping("/product/updateDiscount")
     void updateDiscount(@RequestParam(value = "haveDiscount",required = false) int haveDiscount,
                               @RequestParam(value = "id",required = false) int id);

    @RequestMapping("/product/update")
    void update(@RequestParam(value = "name",required = false) String name,
                @RequestParam(value = "price",required = false) Float price,
                @RequestParam(value = "number",required = false) int number,
                @RequestParam(value = "color",required = false) String color,
                @RequestParam(value = "kind",required = false) String kind,
                @RequestParam(value = "haveDiscount",required = false) int haveDiscount,
                @RequestParam(value = "photo",required = false) String photo,
                @RequestParam(value = "id",required = false) int id);

}
